"""
转换坐标系
"""
import os

from osgeo import gdal, gdalconst


# 将坐标系转到WGS84坐标系
def geo2wgs84(input_path, output_path):
    gdal.Warp(output_path, input_path,
              dstSRS="EPSG:4326",
              format="GTiff",
              resampleAlg=gdalconst.GRA_NearestNeighbour)
    print("{} 转换完成".format(input_path))

if __name__ == '__main__':
    input_dir = r"G:\test\SMAP_NEW\reconstructed_sm\sm"
    output_dir = r"G:\test\SMAP_NEW\reconstructed_sm\sm_wgs84"
    for input_name in os.listdir(input_dir):
        input_path = os.path.join(input_dir, input_name)
        output_path = os.path.join(output_dir, input_name)
        geo2wgs84(input_path, output_path)